#pragma once
#include <cmath>
#ifndef MYVECTOR3_H
#define MYVECTOR3_H
class MyVector3{

	public:
		float x,y,z,w;

		MyVector3(){}

		MyVector3(float x, float y, float z, float w){
			this->x = x;
			this->y = y;
			this->z = z;
			this->w = w;
		}
				
		float scalarMult(MyVector3 v) {
			
			float x = this->x*v.x;
			float y = this->y*v.y;
			float z = this->z*v.z;
			return (x + y + z);

//			return ((this->x*v.x) + (this->y*v.y) + (this->z*v.z));
		}

		MyVector3 vectorMult(MyVector3 v) {
			MyVector3 w;
	
			w.x = this->y * v.z - this->z * v.y;
			w.y = this->z * v.x - this->x * v.z;
			w.z = this->x * v.y - this->y * v.x;

			return w;
		}

		MyVector3 constantMult(float a) {
			MyVector3 w;
	
			w.x = this->x * a;
			w.y = this->y * a;
			w.z = this->z * a;

			return w;
		}

		static MyVector3 vectorFromTo(MyVector3 a, MyVector3 b) {
			MyVector3 w;
	
			w.x = b.x - a.x;
			w.y = b.y - a.y;
			w.z = b.z - a.z;

			return w;
		}

		void turnVector() {
				
			this->x = -this->x;
			this->y = -this->y;
			this->z = -this->z;

		}

		float size() const{
			
			float x = this->x * this->x;
			float y = this->y * this->y;
			float z = this->z * this->z;
			float size = sqrtf(x + y + z);
			return size;
			
//			return sqrtf(x * x + y * y + z * z);
		}

		MyVector3 plus(MyVector3 u){
		
			u.x = this->x + u.x;
			u.y = this->y + u.y;
			u.z = this->z + u.z;
			return u;
		}

		MyVector3 minus(MyVector3 u){
		
			u.x = this->x - u.x;
			u.y = this->y - u.y;
			u.z = this->z - u.z;

			return u;
		}

		MyVector3 krat(MyVector3 u){
		
			u.x = this->x * u.x;
			u.y = this->y * u.y;
			u.z = this->z * u.z;

			return u;
		}

		MyVector3 deleno(MyVector3 u){
		
			u.x = this->x / u.x;
			u.y = this->y / u.y;
			u.z = this->z / u.z;

			return u;
		}

		void normalize() {
		
		//float size = sqrt(vector.x*vector.x + vector.y * vector.y + vector.z * vector.z + vector.w*vector.w);
		float size = sqrtf(this->x*this->x + this->y * this->y + this->z * this->z);
		
		this->x = this->x / size;
		this->y = this->y / size;
		this->z = this->z / size;
		//vector.w = vector.w / size;

		//printf("%f ",vector.x);

	}
};

#endif